home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10842 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.8 KB  |  65 lines

  1. Path: uuneo.neosoft.com!usenet
  2. From: Wmatthew@lan-aces.com (W. Matthews)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Can you explain this?
  5. Date: 11 Mar 1996 14:35:45 GMT
  6. Organization: LAN-ACES, Inc.
  7. Message-ID: <4i1do1$b7i@uuneo.neosoft.com>
  8. References: <4hjijm$370@dfw-ixnews1.ix.netcom.com>
  9. NNTP-Posting-Host: 198.65.178.8
  10. X-Newsreader: WinVN 0.92.5
  11.  
  12. In article <4hjijm$370@dfw-ixnews1.ix.netcom.com>, yurif@ix.netcom.com (Yuri Finkelstein) says:
  13. >
  14. >Can anybody explain why this tiny piece of code doesn't work in CASE1
  15. >( linker error )? Or it's just MSVC 4.0 specific?
  16. >Any help will be appreciated.
  17. >//--------------------------------------------------------------------------------------
  18. >#define CASE1
  19. >//#define CASE2
  20. >//#define CASE3
  21. >
  22. >template <class T> void SetParam( T* pT, int a )
  23. >{
  24. >        pT->m_a = a;
  25. >}
  26. >
  27. >class FOO
  28. >{
  29. >
  30. >#ifdef CASE3
  31. >public:
  32. >#endif
  33. >        int m_a;
  34. >
  35. >#ifdef CASE1
  36. >        friend void SetParam( FOO* pFOO, int a );
  37. >#endif
  38. >
  39. >public:
  40. >        void Bar( int a ) { SetParam( this, a ); }
  41. >}
  42. >
  43. >int main()
  44. >{
  45. >        FOO foo;
  46. >        foo.Bar( 5 );
  47. >        return 0;
  48. >}
  49. >------------------------------------------------
  50. >Yuri Finkelstein
  51. >(415) 389-0653 (home)
  52. >
  53. I did not see a reply to this, but, (and I may be wrong) don't you have to
  54. instantiate SetParam since you made a template?
  55. Please, if I'm wrong let me know.
  56. ______________________________________________
  57. |Wyatt Matthews:       Tech Support Department |
  58. |WMATTHEW@LAN-ACES.COM        -Internet-       |
  59. |WMATTHEW.MHS@LAN-ACES          -MHS-          |
  60. |LAN-ACES Tech Support      (713)890-9786      |
  61. |LAN-ACES BBS               (713)890-9790      |
  62. |LAN-ACES Fax               (713)890-9731      |
  63. |LAN-ACES Sales             (713)890-9787      |
  64. ______________________________________________
  65.